#include "widget.h"
#include "ui_widget.h"
#include <QTimer>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    timer=new QTimer(this);
    connect(timer,&QTimer::timeout,this,&Widget::hander);//到时间后触发
    timer->start(100);//设置多长时间之后触发
}

Widget::~Widget()
{
    delete ui;
}

void Widget::hander()
{
    int value=ui->progressBar->value();
    if(value>=100)
    {
        this->timer->stop();
        return;
     }
     ui->progressBar->setValue(value+1);
}
